package com.iw.point.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iw.adoms.action.BaseAction;
import com.iw.adoms.entity.Marchandise;
import com.iw.adoms.service.MarchandiseService;
import com.iw.core.orm.PageData;
import com.iw.core.utils.WebUtils;

@Controller
@RequestMapping("/point")
public class PointAction extends BaseAction {

	@Autowired
	private MarchandiseService mService;

	@RequestMapping("/setting")
	public ModelMap setting(HttpServletRequest request) {
		PageData<Marchandise> pageData = new PageData<Marchandise>();
		// 给pageData设置参数
		WebUtils.setPageDataParameter(request, pageData);
		pageData = mService.find(pageData);

		return new ModelMap(pageData);
	}

	@RequestMapping("/save/setting/{id}")
	@ResponseBody
	public boolean saveSetting(@PathVariable("id") Integer id, double point) {
		Marchandise m = mService.find(id);
		m.setPoint(point);
		mService.update(m);
		return true;
	}

	@RequestMapping("/service400")
	public String service400(HttpServletRequest request) {
		return "";
	}

}
